package com.wang.mapstruct.controller;

import com.wang.mapstruct.convert.UserConvert;
import com.wang.mapstruct.model.UserDTO;
import com.wang.mapstruct.model.UserVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author: wangning
 * @date: 2024/1/2 19:54
 */
@RestController
public class UserController {

    @PostMapping("/map")
    public UserVO map(@RequestBody UserDTO userDTO){
        return UserConvert.USER_CONVERT.dto2vo(userDTO);
    }

    @PostMapping("/maps")
    public List<UserVO> maps(@RequestBody UserDTO userDTO){
        ArrayList<UserDTO> arrayList = new ArrayList<>();
        arrayList.add(userDTO);
        arrayList.add(userDTO);
        return UserConvert.USER_CONVERT.dto2vo(arrayList);
    }

}
